<?php
include("../../news/model.php");
include("../../type/model.php");
include("../view/basefunction.php");

// 从数据库里查询出这个产品的信息
$news = model_get_news_details($_GET["id"]);
$type_list = get_type_list("news");
$body_html = represent_edit_form($news, $type_list);

include_once("../template/layout.php");

// ---------------------------------
// view
// ---------------------------------
function represent_edit_form($news, $type_list)
{
	$htmlData = '';
	if (!empty($news['content']))
 	{
		if (get_magic_quotes_gpc())
 		{
			$htmlData = stripslashes($news['content']);
		}
		else
		{
			$htmlData = $news['content'];
		}
	}

	$form_html =
"<script charset='utf-8' src='../editor/kindeditor.js'></script>
<script>
	KE.show({
		id : 'content',
		cssPath : './index.css',
		afterCreate : function(id) {
			KE.event.ctrl(document, 13, function() {
				KE.sync(id);
				document.forms['example'].submit();
			});
			KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
				KE.sync(id);
				document.forms['example'].submit();
			});
		}
	});
</script>
<form action='./edit_post.php' method='post' enctype='multipart/form-data'>
<input type='hidden' name='id' value='" . $news['id'] . "'/>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000' />
新闻标题：<input type='text' name='title' value='" . $news['title'] . "' /><br />
所属分类：" . represent_type_list($type_list, $news['type_id'], "news") . "<br />
内容：<br />
<textarea id='content' name='content' style='width:700px;height:300px;visibility:hidden;'>"
. htmlspecialchars($htmlData) .
"</textarea>
<input type='submit' value='更新' />
</form>";
	return $form_html;
}
?>
